//
//  MListViewController.m
//  NeusoftHBSJSober
//
//  Created by Apple-21 on 15/10/28.
//  Copyright (c) 2015年 com.neusoftsober. All rights reserved.


#import "MListViewController.h"
#import "MHomeViewController.h"
#import "MListModel.h"
#import "MDDataBaseUtil.h"
#import "MJRefresh.h"
#import "MViewUtil.h"
#import "MBProgressHUD.h"
#import "MListDataViewController.h"
@interface MListViewController ()<MJRefreshBaseViewDelegate> {

    NSInteger index;
    // 附近列表返回的数组
    NSArray *categoryArr;
    
    // 附近列表 左边选中的索引值
    NSInteger cateIndex;
    
    // 附近列表 左边选中的字符串
    NSString *selectCateString;
    
    // 左边表格的竖线
    UIView *lineView;
    
    NSString *kid;
    
    NSArray *kTypeArray;
    
    NSMutableDictionary *mutableDict;
    
    NSString *selectString;
    
    NSString *selectString2;
    // 存放列表数据
    NSMutableArray *listDataModelMutArr;
    NSMutableArray *tempDataMutArray;
    MViewUtil *viewUtil;
    MListDataViewController *mListDataVC;
    
   
    
}

@property (nonatomic, strong) MJRefreshHeaderView *headerRefresh;
@property (nonatomic, strong) MJRefreshFooterView *footRefresh;

@property (nonatomic, strong) NSString *Kid;
@property (nonatomic, strong) NSString *latitude;
@property (nonatomic, strong) NSString *longtitude;
@property (nonatomic, strong) NSString *typeId;
@property (nonatomic, strong) NSString *priceId;
@property  NSInteger pageIndex;
@property (nonatomic, strong) NSString *radius;
@property (nonatomic, strong) NSString *sort;
@property (nonatomic, strong) NSString *sizeId;
@property (nonatomic, strong) NSMutableArray *dataMutArray;

@property (nonatomic) NSInteger selectedTypeIndex;
@property  NSInteger selectedPriceIndex;
@property  NSInteger selectedOtherIndex;
@end

@implementation MListViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    //  初始化刷新
    [self _initRefresh];
//    [self _loadDataWithRefreshFlag:YES];
    // 初始化列表 可变数组
    listDataModelMutArr = [NSMutableArray array];
    
    kTypeArray = [NSArray arrayWithObjects:@"类型",@"价格",@"其他", nil];

//    // 初始化表格左边的竖线
//    lineView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 2, 36)];
//    lineView.backgroundColor = INDAIN_RED;
//    [self.nearCategoryTableView addSubview:lineView];
//    [self.categoryTableView addSubview:lineView];
    self.nearDetialTableView.tableFooterView=[[UITableView alloc]init];
    
    self.cellNib = [UINib nibWithNibName:@"MListCell" bundle:nil];
    // 可变view 默认为隐藏
    [self.baseSelectView setHidden:YES];
    [self.disBtn500 setSelected:YES];
    [self.distanceBtn setTitle:@"500米" forState:UIControlStateNormal];
    [MDDataBaseUtil setTxtLatitude:@"23.01808"];
    [MDDataBaseUtil setTxtLongtitude:@"113.146539"];
    [self.nearBtn setTitle:@"全部" forState:UIControlStateNormal];
    
    mListDataVC = [[MListDataViewController alloc]init];
    
}
- (id)init
{
    self = [super init];
    if (self) {
        [self dataInitialize];
    }
    return self;
}

- (void)dataInitialize {

    self.Kid = @"0";
    self.latitude = [MDDataBaseUtil txtLatitude];
    self.longtitude = [MDDataBaseUtil txtLongtitude];
    self.typeId = nil;
    self.priceId = nil;
    self.sort = @"Price";
    self.pageIndex = 0;
    self.radius = @"10000";
    self.sizeId = nil;
}
- (void)viewDidAppear:(BOOL)animated {

    
}
- (void)viewWillAppear:(BOOL)animated {
    //从接口 设置表格数据
    [self readNearByData];
    
    if (listDataModelMutArr.count == 0) {
        [self.headerRefresh beginRefreshing];
    }
    
//    // 默认 附近列表选中第一行
//    NSIndexPath *indexPath = [NSIndexPath indexPathForRow:0 inSection:0];
//    [self.nearCategoryTableView selectRowAtIndexPath:indexPath animated:YES scrollPosition:UITableViewScrollPositionBottom];
//    [self.categoryTableView selectRowAtIndexPath:indexPath animated:YES scrollPosition:UITableViewScrollPositionBottom];

    // 大button 默认隐藏
    [self.hiddeBtn setHidden:YES];
    [self.hiddeBtn setEnabled:NO];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
- (void)dealloc {

    self.headerRefresh = nil;
    self.footRefresh = nil;
}
- (void)refreshViewBeginRefreshing:(MJRefreshBaseView *)refreshView {

    if (refreshView == self.headerRefresh) {
        [self _loadDataWithRefreshFlag:YES];
    } else {
    
        [self _loadDataWithRefreshFlag:NO];
    }
}
- (void)_loadDataWithRefreshFlag:(BOOL)flag {

    viewUtil = [[MViewUtil alloc]init];
    
    if (flag) {
        self.pageIndex = 0;
    }
    [[MListServices sharedClient]getProductListWithKid:self.Kid latitude:self.latitude longtitude:self.longtitude radius:self.radius sort:self.sort typeId:self.typeId priceId:self.priceId sizeId:self.sizeId pageIndex:[NSString stringWithFormat:@"%ld",(long)self.pageIndex] completion:^(NSMutableArray *result) {
            if (result.count == 0) {

                [viewUtil showShortDurationMessage:@"没有数据" targetView:self.view];

            } else {
                if (flag) {
                    self.dataMutArray = [NSMutableArray array];
                }
                self.pageIndex += 1;
                [self.dataMutArray addObjectsFromArray:result];
                
                MHomeViewController *homeVC = (MHomeViewController *)[[[MViewUtil alloc]init]getViewControllerWithView:self.view ];
                
                NSMutableDictionary *merchantMutDict = [NSMutableDictionary new];
                for (MListModel *model in self.dataMutArray) {
                    [merchantMutDict setObject:model forKey:model.companyName];
                }
                homeVC.mapViewController.merchantMutDict = merchantMutDict;
                
                [self.myListTableView reloadData];
                
                
            }
        
            [NSTimer scheduledTimerWithTimeInterval:0.5
                                              target:self
                                            selector:@selector(endRefreshing)
                                            userInfo:nil
                                             repeats:NO];
            }
               failure:^(NSString *error){
                   
                   [viewUtil showShortDurationMessage:@"网络异常" targetView:self.view];
                   [NSTimer scheduledTimerWithTimeInterval:0.5
                                                    target:self
                                                  selector:@selector(endRefreshing)
                                                  userInfo:nil
                                                   repeats:NO];

               }];
}
- (void)endRefreshing {

    [self.headerRefresh endRefreshing];
    [self.footRefresh endRefreshing];
}
#pragma mark  refresh
- (void)_initRefresh {
    
    self.headerRefresh = [[MJRefreshHeaderView alloc]initWithScrollView:self.myListTableView];
    self.headerRefresh.delegate = self;
    self.footRefresh = [[MJRefreshFooterView alloc]initWithScrollView:self.myListTableView];
    self.footRefresh.delegate = self;
}
#pragma mark 表格行数
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    if (tableView == self.myListTableView) {// 列表页 table
            return self.dataMutArray.count;
    } else if (tableView == self.nearCategoryTableView) {// 附近列表 左边table
        return categoryArr.count;
    } else if (tableView == self.nearDetialTableView) {// 附近列表 右边table
    
        NSDictionary *dict = [categoryArr objectAtIndex:cateIndex];
        NSArray *valuesArray = [dict objectForKey:@"values"];
        return valuesArray.count;
    }else if (tableView == self.categoryTableView){// 类别列表  左边
        return kTypeArray.count;
    }else if (tableView == self.categoryDetailTableView){// 类别列表 右边
        
        NSMutableArray *arr = [NSMutableArray array];
        for (NSDictionary *dict in [mutableDict objectForKey:selectString]) {
            [arr addObject:dict[@"name"]];
        }
        return arr.count;
    }else {
    
        return 5;
    }
    
}
#pragma mark 单元格内容
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    if (tableView == self.myListTableView) {// 列表页 table
        static NSString *cellStr = @"Idetifier";
        MListCell *cell = (MListCell *)[tableView dequeueReusableCellWithIdentifier:cellStr];
        
        if (cell == nil) {
            
            [self.cellNib instantiateWithOwner:self options:nil];
            
            cell = self.listCell;
            self.listCell = nil;
        }
        if (indexPath.row<=[self.dataMutArray count]) {
            MListModel *model = [self.dataMutArray objectAtIndex:indexPath.row];
            cell.priceLabel.text = [NSString stringWithFormat:@"%@元",model.price];
            cell.titleLabel.text = model.title;
            cell.distanceLabel.text = [NSString stringWithFormat:@"%@米",model.distance];
            cell.companyLable.text = model.companyName;
            
            // 地图图标 添加点击事件
            [cell.mapBtn addTarget:self action:@selector(mapBtnAction:) forControlEvents:UIControlEventTouchUpInside];
            [cell.mapBtn setTag:indexPath.row];
            
            [cell.mapBtn setTitle:((MListModel *)self.dataMutArray[indexPath.row]).latitude forState:UIControlStateNormal];
            [cell.mapBtn setTitle:((MListModel *)self.dataMutArray[indexPath.row]).longtitude forState:UIControlStateHighlighted];
            [cell.mapBtn setTitle:((MListModel *)self.dataMutArray[indexPath.row]).companyName forState:UIControlStateSelected];
            
            cell.selectionStyle = UITableViewCellSelectionStyleNone;
            return cell;

        }
           } else if (tableView == self.nearCategoryTableView) {// 附近列表  左边table
    
        static NSString *cellStr = @"categoryIdentifier";
        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellStr];
        if (cell == nil) {
            cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellStr];
        }
        NSDictionary *dict = [categoryArr objectAtIndex:indexPath.row];
        cell.textLabel.text = [dict objectForKey:@"name"];
        
        cell.selectionStyle = UITableViewCellSelectionStyleDefault;
        cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
        return cell;
    } else if (tableView == self.nearDetialTableView) {// 附近列表  右边table
    
        static NSString *cellStr = @"priceCateIdentifier";
        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellStr];
        if (cell == nil) {
            cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellStr];
        }
        NSDictionary *dict = [categoryArr objectAtIndex:cateIndex];
        NSArray *valuesArr = [NSArray array];
        valuesArr = [dict objectForKey:@"values"];
        cell.textLabel.text = [valuesArr objectAtIndex:indexPath.row];
        
        
        if ([cell.textLabel.text isEqualToString:selectCateString]) {
            cell.accessoryType = UITableViewCellAccessoryCheckmark;
            selectCateString = nil;
        } else {
            cell.accessoryType = UITableViewCellAccessoryNone;
        }
        cell.backgroundColor = GAINSBORO;
        tableView.backgroundColor = GAINSBORO;
        return cell;
    }else if(tableView == self.categoryTableView){
        static NSString *cellStr = @"CategoryIdentifier";
        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellStr];
        if (cell == nil) {
            cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellStr];
        }
        cell.textLabel.text = [kTypeArray objectAtIndex:indexPath.row];
        return cell;
    }else if (tableView == self.categoryDetailTableView){
        
        static NSString *cellStr = @"CateIdentifier";
        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellStr];
        if (cell == nil) {
            cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellStr];
        }
        NSMutableArray *arr = [NSMutableArray array];
        NSDictionary *allDict = @{@"id":@"0",@"name":@"全部"};
        [arr addObject:allDict[@"name"]];
        for (NSDictionary *dict in [mutableDict objectForKey:selectString]) {
            [arr addObject:dict[@"name"]];
        }
        cell.textLabel.text = [arr objectAtIndex:indexPath.row];
        if ([cell.textLabel.text isEqualToString:selectString2]) {
            cell.accessoryType = UITableViewCellAccessoryCheckmark;
            selectString2 = nil;
        }
        else {
            cell.accessoryType = UITableViewCellAccessoryNone;
        }
        
        cell.backgroundColor = GAINSBORO;
        tableView.backgroundColor = GAINSBORO;

         return cell;
    }

    return nil;
}
#pragma mark  单元格 选中
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    
    if (tableView == self.myListTableView) {
        
        MListModel *model = [self.dataMutArray objectAtIndex:indexPath.row];
        mListDataVC.model = model;
        
        mListDataVC.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
        [self presentViewController:mListDataVC animated:YES completion:nil];
        
        
    } else if (tableView == self.nearCategoryTableView) {
    
        cateIndex = indexPath.row;
        [self.nearDetialTableView reloadData];
    }else if (tableView == self.nearDetialTableView) {
    
        NSDictionary *dict = [categoryArr objectAtIndex:cateIndex];
        NSArray *valuesArr = [NSArray array];
        valuesArr = [dict objectForKey:@"values"];
        
        selectCateString = [valuesArr objectAtIndex:indexPath.row];
        [self.nearDetialTableView reloadData];
        
        if ([selectCateString isEqualToString:@"全部"]) {
            [self dataInitialize];
            [self.headerRefresh beginRefreshing];
            [self _loadDataWithRefreshFlag:YES];
            
        }
        [self _loadKeyListModel];
        MHomeViewController *main=(MHomeViewController*) [self getViewControllerWithView:self.view];

        main.titleLabel.text=[valuesArr objectAtIndex:indexPath.row];
        // 隐藏可变view
        [self.baseSelectView setHidden:YES];
        [self.nearBtn setTitle:selectCateString forState:UIControlStateNormal];
        // 隐藏大button
        if (self.hiddeBtn.hidden == NO) {
            [self.hiddeBtn setHidden:YES];
            [self.hiddeBtn setEnabled:NO];
        }
    }else if (tableView == self.categoryTableView) {
        selectString =[kTypeArray objectAtIndex:indexPath.row];
        [self.categoryDetailTableView reloadData];
    } else if (tableView == self.categoryDetailTableView) {
        NSMutableArray *arr = [NSMutableArray array];
        NSMutableArray *idArr = [NSMutableArray array];
        NSDictionary *allDict = @{@"id":@"0",@"name":@"全部"};
        [arr addObject:allDict[@"name"]];
        [idArr addObject:allDict[@"id"]];
        for (NSDictionary *dict in [mutableDict objectForKey:selectString]) {
            
            [arr addObject:dict[@"name"]];
            [idArr addObject:dict[@"id"]];
        }
        selectString2 = [arr objectAtIndex:indexPath.row];
        
        [self.categoryDetailTableView reloadData];
        self.baseSelectView.hidden=YES;
        
        if ([selectString isEqualToString:@"类型"]) {
            self.selectedTypeIndex = indexPath.row;
            if (self.selectedTypeIndex == 0) {
                self.typeId = nil;
            } else {
                self.typeId = [idArr objectAtIndex:self.selectedTypeIndex];
            }

            
        } else if ([selectString isEqualToString:@"价格"]) {
        
            self.selectedPriceIndex = indexPath.row;
            if (self.selectedPriceIndex == 0) {
                self.priceId = nil;
            }else {
            
                self.priceId = [idArr objectAtIndex:self.selectedPriceIndex];
            }
        } else if ([selectString isEqualToString:@"其他"]) {
        
            self.selectedOtherIndex = indexPath.row;
            if (self.selectedOtherIndex == 0) {
                self.sizeId = nil;
            } else {
            
                self.sizeId = [idArr objectAtIndex:self.selectedOtherIndex];
            }

        } else {
        
            self.typeId = nil;
            self.priceId = nil;
            self.sizeId = nil;
        }
        [self.headerRefresh beginRefreshing];
        [self _loadDataWithRefreshFlag:YES];
        [self.categoryBtn setTitle:selectString2 forState:UIControlStateNormal];

    }
}
#pragma mark loadkeywordBykid
- (void)_loadKeyListModel{

    [[MListServices sharedClient]getKIDwithKeyword:selectCateString completion:^(NSString *kidResult) {
        kid = [NSString stringWithString:kidResult];
        [[MListServices sharedClient] getKTypeWithKid:kid comletion:^(NSDictionary *result) {
            
            mutableDict = [NSMutableDictionary dictionary];
            
            [mutableDict setValue:[result objectForKey:@"ktype"] forKey:[kTypeArray objectAtIndex:0]];
            [mutableDict setValue:[result objectForKey:@"kprice"] forKey:[kTypeArray objectAtIndex:1]];
            [mutableDict setValue:[result objectForKey:@"kother"]forKey:[kTypeArray objectAtIndex:2]];
            self.Kid = kid;
            self.typeId = nil;
            self.priceId = nil;
            self.sizeId = nil;
            [self.categoryBtn setTitle:@"类型" forState:UIControlStateNormal];
            // 默认 附近列表选中第一行
            NSIndexPath *indexPath = [NSIndexPath indexPathForRow:0 inSection:0];
            [self.categoryTableView selectRowAtIndexPath:indexPath animated:YES scrollPosition:UITableViewScrollPositionBottom];
            
            [self.categoryTableView reloadData];
            [self.categoryDetailTableView reloadData];
            
            [self.headerRefresh beginRefreshing];
            [self _loadDataWithRefreshFlag:YES];
        }
                                              failure:^(NSString *error){
                                              }];
    }
                                           failure:^(NSString *error){
                                           }];
}
#pragma mark 点击地图图标
- (void)mapBtnAction:(UIButton *)sender {

    MHomeViewController *homeVC = (MHomeViewController *)[[[MViewUtil alloc]init] getViewControllerWithView:self.view];

    MListModel *model = [[MListModel alloc]init];
    model = self.dataMutArray[sender.tag];
    
    NSMutableDictionary *dict = [NSMutableDictionary dictionary];
    [dict setObject:self.dataMutArray[sender.tag] forKey:model.companyName];
    homeVC.mapViewController.merchantMutDict = [NSMutableDictionary dictionaryWithDictionary:dict];
    [homeVC clickListCellMapButtonAction:sender];
}
#pragma mark 点击“距离”，“类别”，“附近”按钮的方法
- (IBAction)selectAction:(UIButton *)sender {
    MHomeViewController *main=(MHomeViewController*) [self getViewControllerWithView:self.view];
    main.menuView.hidden=YES;
    UIButton *button = (UIButton *)sender;
    NSInteger tag = button.tag;
    if (self.baseSelectView.isHidden == YES) {
        [self.baseSelectView setHidden:NO];
        
        [self.hiddeBtn setHidden:NO];
        [self.hiddeBtn setEnabled:YES];
        
        // 设置可变view的frame值
        self.baseSelectView.frame = CGRectMake(0, 42, SCREENWIDTH, 240);
        [self.view addSubview:self.baseSelectView];
        [self.view bringSubviewToFront:self.baseSelectView];
        // 移除三个view
        [self.distanceView removeFromSuperview];
        [self.categoryView removeFromSuperview];
        [self.nearView removeFromSuperview];
        [self checkBtn:tag];
    }else {
        // 移除三个view
        [self.distanceView removeFromSuperview];
        [self.categoryView removeFromSuperview];
        [self.nearView removeFromSuperview];
        if (index == tag) {
            [self.baseSelectView setHidden:YES];
            [self.hiddeBtn setHidden:YES];
            [self.hiddeBtn setEnabled:NO];
            index = 0;
        } else {
            [self checkBtn:tag];
        }
    }
}
- (void)checkBtn:(NSInteger)tag{
    
    if (tag == 10) {// distance
        self.distanceView.frame = CGRectMake(0, 0, SCREENWIDTH, 100);
        [self.baseSelectView addSubview:self.distanceView];
    } else if (tag == 20) {// category
        self.categoryView.frame = CGRectMake(0, 0, SCREENWIDTH, 240);
        [self.baseSelectView addSubview:self.categoryView];
    } else {// nearBy
        self.nearView.frame = CGRectMake(0, 0, SCREENWIDTH, 240);
        [self.baseSelectView addSubview:self.nearView];
    }
    index = tag;
}
#pragma mark 点击附近列表，main view的label显示
-(UIViewController *)getViewControllerWithView:(UIView *)view{
    for (UIView *next=view.superview;next;next=next.superview) {
        UIResponder *nextResponder=[next nextResponder];
        if ([nextResponder isKindOfClass:[UIViewController class]]) {
            return (UIViewController *)nextResponder;
        }
    }
    return nil;
}
#pragma mark 点击 具体距离
- (IBAction)clickDistanceAction:(UIButton *)sender {
    
    UIButton *button = (UIButton *)sender;
    NSInteger tag = button.tag;
    for (UIView *view in sender.superview.subviews) {
        
        if ([view isKindOfClass:[UIButton class]]) {
            ((UIButton *)view).selected = NO;
        }
    }
    [self.distanceBtn setTitle:[NSString stringWithFormat:@"%ld米",(long)tag] forState:UIControlStateNormal];
    self.radius = [NSString stringWithFormat:@"%ld",(long)tag];
    [self.headerRefresh beginRefreshing];
    [self _loadDataWithRefreshFlag:YES];
    sender.selected = YES;
    // 隐藏可变view
    [self.baseSelectView setHidden:YES];
    // 隐藏大button
    if (self.hiddeBtn.hidden == NO) {
        [self.hiddeBtn setHidden:YES];
        [self.hiddeBtn setEnabled:NO];
    }
    
}
#pragma mark 点击大button，隐藏可变view
- (IBAction)clickHiddenAction:(UIButton *)sender {
    
    [self.baseSelectView setHidden:YES];
    [self.hiddeBtn setEnabled:NO];
    [self.hiddeBtn setHidden:YES];
}
#pragma mark 使用AFNetworking第三方框架 get类别的数据。
- (void)menuCategoryData {
    
    [[MListServices sharedClient] getHotKeywordComletion:^(NSMutableArray *array) {
        /**
         *  类别的数组，每个元素都是一个数组，此数组元素都是字典
         *
         */
        NSMutableArray *arr = [NSMutableArray array];
        NSArray *valueArr = [NSArray arrayWithObjects:@"全部", nil];
        NSDictionary *dict = @{@"name":@"全部",@"values":valueArr};
        [arr addObject:dict];
        [arr addObjectsFromArray:array];
        categoryArr = [NSArray arrayWithArray:arr];
    }
                                                failure:^(NSString *error){
                                                    
                                                    NSLog(@"failure");
                                                }];
}
#pragma mark 将附近列表的所有数据保存在本地
- (void)saveNearByData {
    
    NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
    [userDefaults setObject:categoryArr forKey:@"nearListNewData"];
}
#pragma mark 读取附近列表的数据
- (void)readNearByData {
    
    NSUserDefaults *accountDic = [NSUserDefaults standardUserDefaults];
    NSArray *nearDataArr = [NSArray array];
    nearDataArr = [accountDic objectForKey:@"nearListNewData"];
    
    if (nearDataArr.count == 0) {
        [self menuCategoryData];
    } else {
        
        categoryArr = [NSArray arrayWithArray:nearDataArr];
    }
}
#pragma mark  读取主列表数据
- (void)mListData {
    [[MListServices sharedClient]getProductListWithKid:@"0" latitude:@"23.01808" longtitude:@"113.146539" radius:@"10000" sort:@"Price" typeId:nil priceId:nil sizeId:nil pageIndex:@"0" completion:^(NSMutableArray *result) {
                                            
        if (result.count == 0) {
            NSLog(@"没有更多数据了");
        } else {
        
            for (MListModel *model in result) {
                
                [listDataModelMutArr addObject:model];
            }
            [self.myListTableView reloadData];
        }
    }
       failure:^(NSString *error){
       
           NSLog(@"failure");
       }];
}

@end
